package com.apache.passport.common;

import javax.xml.bind.JAXBContext;
import javax.xml.bind.JAXBException;
import javax.xml.bind.Unmarshaller;
import java.io.IOException;
import java.io.StringReader;

public class JaxbUtil {

	public static <T> T xmlToBean(String xmlStr,Class<T> b) throws JAXBException {
		JAXBContext context = JAXBContext.newInstance(b);
		Unmarshaller shaller = context.createUnmarshaller();
		return (T)shaller.unmarshal(new StringReader(xmlStr));
	}
}
